We can't print shorthands, so don't try.
In particular, I want to get away from shorthands being representable
using GValue, and this function kinda requires that.
for (walk = keys; walk; walk = walk->next)
{
- GtkStyleProperty *prop = walk->data;
+ GtkCssStyleProperty *prop = walk->data;
const PropertyValue *value = g_hash_table_lookup (ruleset->style, prop);
g_string_append (str, " ");
- g_string_append (str, _gtk_style_property_get_name (prop));
+ g_string_append (str, _gtk_style_property_get_name (GTK_STYLE_PROPERTY (prop)));
g_string_append (str, ": ");
- _gtk_style_property_print_value (prop, &value->value, str);
+ _gtk_css_style_property_print_value (prop, &value->value, str);
g_string_append (str, ";\n");
}
#include "gtkcssstylepropertyprivate.h"
+#include "gtkcssstylefuncsprivate.h"
+#include "gtkcsstypesprivate.h"
#include "gtkintl.h"
+#include "gtkprivatetypebuiltins.h"
enum {
PROP_0,
return &property->initial_value;
}
+/**
+ * _gtk_css_style_property_print_value:
+ * @property: the property
+ * @value: the value to print
+ * @string: the string to print to
+ *
+ * Prints @value to the given @string in CSS format. The @value must be a
+ * valid specified value as parsed using the parse functions or as assigned
+ * via _gtk_style_property_assign().
+ **/
+void
+_gtk_css_style_property_print_value (GtkCssStyleProperty *property,
+ const GValue *value,
+ GString *string)
+{
+ g_return_if_fail (GTK_IS_CSS_STYLE_PROPERTY (property));
+ g_return_if_fail (value != NULL);
+ g_return_if_fail (string != NULL);
+
+ if (G_VALUE_HOLDS (value, GTK_TYPE_CSS_SPECIAL_VALUE))
+ {
+ GEnumClass *enum_class;
+ GEnumValue *enum_value;
+
+ enum_class = g_type_class_ref (GTK_TYPE_CSS_SPECIAL_VALUE);
+ enum_value = g_enum_get_value (enum_class, g_value_get_enum (value));
+
+ g_string_append (string, enum_value->value_nick);
+
+ g_type_class_unref (enum_class);
+ }
+ else if (GTK_STYLE_PROPERTY (property)->print_func)
+ (* GTK_STYLE_PROPERTY (property)->print_func) (value, string);
+ else
+ _gtk_css_style_print_value (value, string);
+}
+
const GValue * _gtk_css_style_property_get_initial_value
(GtkCssStyleProperty *property);
+void _gtk_css_style_property_print_value (GtkCssStyleProperty *property,
+ const GValue *value,
+ GString *string);
+
G_END_DECLS
#endif /* __GTK_CSS_STYLE_PROPERTY_PRIVATE_H__ */
/*** IMPLEMENTATIONS ***/
-static void
-enum_print (int value,
- GType type,
- GString *string)
-{
- GEnumClass *enum_class;
- GEnumValue *enum_value;
-
- enum_class = g_type_class_ref (type);
- enum_value = g_enum_get_value (enum_class, value);
-
- g_string_append (string, enum_value->value_nick);
-
- g_type_class_unref (enum_class);
-}
-
static gboolean
font_family_parse (GtkCssParser *parser,
GFile *base,
return _gtk_css_style_parse_value (value, parser, base);
}
-void
-_gtk_style_property_print_value (GtkStyleProperty *property,
- const GValue *value,
- GString *string)
-{
- if (G_VALUE_HOLDS (value, GTK_TYPE_CSS_SPECIAL_VALUE))
- enum_print (g_value_get_enum (value), GTK_TYPE_CSS_SPECIAL_VALUE, string);
- else if (property && property->print_func)
- (* property->print_func) (value, string);
- else
- _gtk_css_style_print_value (value, string);
-}
-
static void
_gtk_style_property_default_value (GtkStyleProperty *property,
GtkStyleProperties *properties,
GValue *value,
GtkCssParser *parser,
GFile *base);
-void _gtk_style_property_print_value (GtkStyleProperty * property,
- const GValue *value,
- GString *string);
GType _gtk_style_property_get_value_type(GtkStyleProperty * property);
void _gtk_style_property_query (GtkStyleProperty * property,